package com.ming.sevice.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ming.mapper.SysUserMapper;
import com.ming.domain.SysUser;
import com.ming.sevice.SysUserService;
import org.springframework.util.StringUtils;

/**
 *@Author:何元才
 *@Desc:
 *@data:2021-03-31 15:24
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService{

    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 分页查询后台管理员的接口
     *
     * @param page
     * @param sysUser
     * @return
     */
    @Override
    public Page<SysUser> findSysUserByPage(Page<SysUser> page, SysUser sysUser) {
        //分页查询 根据创建时间排序
        page.addOrder(OrderItem.desc("create_time"));
        return sysUserMapper.selectPage(page,new LambdaQueryWrapper<SysUser>()
                .like(StringUtils.hasText(sysUser.getUsername()),SysUser::getUsername,sysUser.getUsername())
        );
    }
}
